package com.hx.io.transferstream;

import java.io.*;

/**
 * @author jxlgcmh
 * @create 2019-05-09 18:33
 * <p>
 * 字节流转换为字符流
 */
public class Demo1 {
    public static void main(String[] args) throws Exception {
        InputStreamReader reader = new InputStreamReader(new FileInputStream("a.txt"), "UTF-8");
        OutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream("b.txt"), "gbk");
        int len;
        char[] buf = new char[1024];
        while ((len = reader.read(buf)) != -1) {
            writer.write(buf, 0, len);
        }
        reader.close();
        writer.close();
    }
}
